/*
 Copyright 2006 Mark E Shepherd

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

package com.adobe.flex.extras.controls.springgraph
{
	import mx.core.UIComponent;
	import mx.containers.VBox;
	import mx.containers.Canvas;
	import mx.core.IDataRenderer;
	import mx.events.FlexEvent;
	
	import flash.display.GradientType;
	import flash.display.SpreadMethod;
	import flash.display.InterpolationMethod;
	import flash.geom.Matrix;
	import mx.effects.Rotate;
		
	
	/** @private */
	public class DefaultItemView extends Canvas implements IDataRenderer
	{
		[Bindable("dataChange")]
		override public function get data(): Object {
			return _data;
		}
		
		override public function set data(d: Object): void {
			_data = d;
			dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE));
		}
		
		override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
			// We could simply do graphics.beginFill(_color) here, to get a solid color fill.
			// But instead, we'll use a gradient fill to get a simulated 3D effect.
			// TODO: tweak the gradient fill settings to get a better looking gradient
			graphics.clear();
			graphics.beginGradientFill(GradientType.RADIAL, [0xffffff, 0xd52626], [1, 1], [0, 127], 
				null, SpreadMethod.PAD, InterpolationMethod.RGB, 0.75);
			graphics.drawCircle(unscaledWidth / 2, unscaledHeight / 2, unscaledHeight / 2);
			graphics.endFill();
		}
				
		
		private var _data: Object = null; 
	}
}